require('../css/login.less');
document.ready(function(){
  let phonetel=document.querySelector("#phonetel");
  let pass1=document.querySelector("#pass1");
  
  let login=document.querySelector("#login");
  let datadis=document.querySelector(".datadis");
  console.log(datadis);
  
  login.addEventListener('click',function(){
    // window.$$.showmask('cuo','登陆失败',3000)
    // window.$$.showmask('correct-1-mini','登陆成功',3000)
    // window.$$.showmask('correct-1-mini','登陆成功',3000,'×')
    
    

    let phone=phonetel.value
    let  pass= pass1.value
     if(!$$.phonefn(phone)){
      datadis.textContent="你输入的账号有误"

     }else if(!$$.pasfn1(pass)){
      datadis.textContent="请输入以字母开头的密码"
     }else{
      
       axios.post(window.$$.username+"/users/login",{
        "account":phone,
        "password":pass
        
       }).then(function(res){
       let  ret=res.data;
        
      console.log(ret.data);
      
         
       if(ret.status===0){
         window.setTimeout(function(){
          window.location.href="./home.html"
        },3000); 
        window.$$.showmask('correct-1-mini','登陆成功',3000)
        localStorage.setItem("user",JSON.stringify(ret.data.user))
        
       }else if(ret.status===555){
        window.$$.showmask('cuo','登陆失败',3000)
       } 
       }).catch(function(error){
       console.log(error);
     
       })

       
  
    
     }
  })


    
})
